<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8" />
<title></title>
<script src="../require/require.js"></script>
<script src="../require/require-config.js"></script>
<script>
	/*<![CDATA[*/
	require([ 'jquery', 'jqxbuttons', 'jqxgrid', 'jqxgrid.selection',
			'jqxgrid.columnsresize' ], function() {
		var access_token;
		//初始化用户列表
		var initUserGuid = function() {
			var url = "../user/1?access_token="+access_token;

			var source = {
				datatype : "json",
				datafields : [ {
					name : 'id',
					type : 'string'
				}, {
					name : 'userName',
					type : 'string'
				}, {
					name : 'phoneNum',
					type : 'string'
				}, {
					name : 'loginCode',
					type : 'string'
				}, {
					name : 'passWord',
					type : 'string'
				} ],
				id : 'id',
				url : url
			};
			var dataAdapter = new $.jqx.dataAdapter(source);
			$("#userGrid").jqxGrid({
				theme : 'darkblue',
				width : '50%',
				height : '30%',
				source : dataAdapter,
				columnsresize : true,
				columns : [ {
					text : '用户名',
					datafield : 'userName',
					width : 100
				}, {
					text : '电话',
					datafield : 'phoneNum',
					width : 100
				}, {
					text : '登录码',
					datafield : 'loginCode',
					width : 100
				}, {
					text : '密码',
					datafield : 'passWord',
					width : 100
				}, ]
			});
		}

		$(document).ready(function() {
			//initUserGuid();
			
			$('#test1').on('click',function(){
				$.ajax({
					type : 'GET',
					url : '../user',
					data : {
						'access_token':access_token
					},
					async : false, //为了简便，设置为同步操作
					cache : false,
					success : function(data) {
						console.log(data);
					}
				});
			});
			$('#test2').on('click',function(){
				initUserGuid();
			});
			$('#test3').on('click',function(){
				
			});
			$.ajax({
				type : 'GET',
				url : '../ui/me',
				data : '',
				async : false, //为了简便，设置为同步操作
				cache : false,
				success : function(data) {
					console.log(data);
					access_token = data.details.tokenValue;
				}
			});

			$(document.body).css('visibility', 'visible');
		})
	});
	/*]]>*/
</script>
</head>
<body style="visibility: hidden; width: 100%; height: 1000px">
	<div id="userGrid"></div>
	<button id = "test1">test1</button>
	<button id = "test2">test2</button>
	<button id = "test3">test3</button>
</body>
</html>